<%= form_for [:shop, @spu_category], html: { class: "card" } do |f| %>
  <div class="card-body">
    <h3 class="card-title">
      <%= @spu_category.new_record? ? "新增分类" : "修改分类"%>
    </h3>
    <div class="row">
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">名字</label>
          <%= f.text_field :name, class: "form-control" %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">图片</label>
          <div class="custom-file">
            <%= f.file_field :avatar, class: "custom-file-input" %>
            <label class="custom-file-label">选择文件</label>
          </div>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">父级分类</label>
          <% if @parent_category.presence %>
            <input type="text" name="parent" value="<%= @parent_category.name %>" class="form-control" disabled>
            <%= f.hidden_field :parent_id, value: @parent_category.id, class: "form-control" %>
          <% else %>
            <input type="text" name="root" value="根分类" class="form-control" disabled>
            <%= f.hidden_field :parent_id, value: 0, class: "form-control" %>
          <% end %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">排序</label>
          <%= f.number_field :sort, class: "form-control" %>
        </div>
      </div>
    </div>
  </div>
  <div class="card-footer text-right">
    <button type="submit" class="btn btn-primary">保 存</button>
  </div>
<% end %>